x11: Deal better with L-shaped monitor arrangements
authorMatthias Clasen <mclasen@redhat.com>
Thu, 22 Mar 2012 21:44:54 +0000 (17:44 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 23 Mar 2012 13:09:14 +0000 (09:09 -0400)
The code for calculating the per-monitor workarea was ignoring
the fact that the EWMH workarea property can only handle rectangular
workareas, and thus can't really do justice to general monitor
arrangements. As a workaround, we ignore it for anything but
the primary monitor. And we ignore it for the primary monitor
as well if it does not even cover it.

https://bugzilla.gnome.org/show_bug.cgi?id=672163

gdk/x11/gdkscreen-x11.c

index c14e065d1b081ff22a60b002368479e939b6437b..a6d8ba6582d0167e63f7a19c34b69bc2a35a5205 100644 (file)
@@ -372,8 +372,19 @@ gdk_x11_screen_get_monitor_workarea (GdkScreen    *screen,
   GdkRectangle workarea;
 
   gdk_x11_screen_get_monitor_geometry (screen, monitor_num, dest);
-  get_work_area (screen, &workarea);
-  gdk_rectangle_intersect (&workarea, dest, dest);
+
+  /* The EWMH constrains workarea to be a rectangle, so it
+   * can't adequately deal with L-shaped monitor arrangements.
+   * As a workaround, we ignore the workarea for anything
+   * but the primary monitor. Since that is where the 'desktop
+   * chrome' usually lives, this works ok in practice.
+   */
+  if (monitor_num == GDK_X11_SCREEN (screen)->primary_monitor)
+    {
+      get_work_area (screen, &workarea);
+      if (gdk_rectangle_intersect (dest, &workarea, &workarea))
+        *dest = workarea;
+    }
 }
 
 static GdkVisual *